//
//  PurpleView.m
//  02-hitTest练习
//
//  Created by J on 16/2/20.
//  Copyright © 2016年 J. All rights reserved.
//

#import "PurpleView.h"

@implementation PurpleView

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
    
    return [super pointInside:point withEvent:event];
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    //判断点在不在chatView上
   CGPoint loc =  [self convertPoint:point toView:self.chatView];
    if ([self.chatView hitTest:loc withEvent:event]) {
        
        return self.chatView;
    }else{
        return  [super hitTest:point withEvent:event];
    }
    
    
    
}

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    UITouch* touch =  [touches anyObject];
    
    CGPoint curP = [touch locationInView:self];
    
    CGPoint preP = [touch previousLocationInView:self];
    
    CGPoint center = self.center;
    center.x +=(curP.x - preP.x);
    center.y +=(curP.y - preP.y);
    self.center = center;


}

@end
